home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / TABAUTO.AML < prev    next >
Text File  |  1996-07-17  |  2KB  |  63 lines

  1. //--------------------------------------------------------------------
  2. // TABAUTO.AML
  3. // Expand Tabs Automatically, (C) 1993-1996 by nuText Systems
  4. //
  5. // Running this macro will automatically expand tab characters (Ascii 9)
  6. // whenever a new file is loaded into an edit window.
  7. //
  8. // To reduce the amount of time required to open large files, only the
  9. // last 200 lines are checked for tab characters. If found, then tabs
  10. // throughout the file are expanded. If tabs are not expanded by this
  11. // macro, the Expand Tabs command can be used to manually expand tabs.
  12. //
  13. // The current tab width (the value of the _TabWidth configuration
  14. // variable) is used as the tab width for the expansion.
  15. //
  16. // Usage:
  17. //
  18. // Select this macro from the Macro List (on the Macro menu), or run it
  19. // from the macro picklist <shift f12>.
  20. //--------------------------------------------------------------------
  21.  
  22. include bootpath "define.aml"
  23.  
  24. // number of ending lines to check for tabs
  25. constant check_lines = 200
  26.  
  27. // check for a previous instance
  28. if object? prf.tabauto then
  29.   if (okbox "Tabauto already installed. Remove it?") == 'Ok' then
  30.     destroyobject prf.tabauto
  31.     prf.tabauto = ''
  32.   end
  33.   return
  34. end
  35. prf.tabauto = getcurrobj
  36.  
  37. // keep this macro resident
  38. resident ON
  39.  
  40. // edit windows only
  41. object edit
  42.  
  43. // called when edit windows are opened
  44. function onopen (options)
  45.   // non-binary files only
  46.   if not getbinarylen then
  47.     oldmark = usemark 'T'
  48.     // create a temp mark at end-of-file
  49.     markline getlines - check_lines + 1 (getlines)
  50.     if find "\t" "bgn*" then      // search for tabs in the mark
  51.       markline 1 (getlines)       // extend mark to the whole file
  52.       tabblock _TabWidth          // expand tabs using TabWidth
  53.       bufferflag '-m'             // turn off buffer-modified flag
  54.     end
  55.     destroymark                   // destroy the temp mark
  56.     usemark oldmark
  57.   end
  58.   passprev options                // pass on to previous onopen
  59. end
  60.  
  61. display
  62. say "Tabauto installed"
  63.